package com.sckylezhang.girl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Controller(处理http请求,必须配合模板使用 )
 * @RestController(Spring4之后新加的注解，原来返回json需要@ResponseBody配合@Controller)
 * @RequestMapping(配置url映射)
 * @PathVariable(获取url中的数据)
 * @RequestParam(获取请求参数的值,不管是get还是post方式都是用这个注解)
 * @GetMapping(组合注解)
 * Created by KyleZhang
 * 2018/3/15 9:21
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private GirlProperties girlProperties;

    //@RequestMapping(value = "/say", method = RequestMethod.GET )
    @GetMapping(value = "/say")
    public String say(@RequestParam(value = "id",required = false/*required：是否必传*/,defaultValue = "30"/*默认值*/) Integer myId){
        return "id: " + myId;
        //return girlProperties.getCupSize();
    }
}